import logging
import  requests
import pytest
import json
def zhmm():
    with open("user.json","r",encoding="utf-8") as f:
        data = json.load(f)
        return data

class Test_wdds():
    uid = ""
    sid = ""
    def setup_method(self):
        print("用例开始执行")

    def theader_method(self):
        print("用例执行结束")


    # @pytest.mark.parametrize("dd",zhmm())
    def test_login(self):
        try:
            url = "http://10.59.9.18/small/user/v1/login"
            data = {"phone":"13811033965","pwd":"123456Aa"}
            res = requests.post(url=url,json=data)
            Test_wdds.uid = res.json()["result"]["userId"]
            Test_wdds.sid = res.json()["result"]["sessionId"]
            print("登录",res.json())
        except Exception as e:
            logging.info(e)
        assert "朱" in res.text

    def test_cxdd(self):
        try:
            url = "http://10.59.9.18/small/order/verify/v1/findOrderListByStatus"
            data = {"status":"9","page":"1","count":"5"}
            hed = {"userId":str(Test_wdds.uid),"sessionId":Test_wdds.sid}
            res = requests.get(url=url,params=data,headers=hed)
            print("查询订单",res.json())
        except Exception as e:
            assert "订单已经完成，无法再做评价！" in res.text
            logging.info(e)


    def test_pl(self):
        try:
            url = "http://10.59.9.18/small/commodity/verify/v1/addCommodityComment?commodityId=5&orderId=2023062414324050429381&content=可以&image"
            hed = {"userId": str(Test_wdds.uid), "sessionId": Test_wdds.sid}
            res = requests.post(url=url,headers=hed)
            print("已经评论过的再次评论", res.json())
        except Exception as e:
            assert res.json()['status'] == 1004
            logging.info(e)

    def test_pl2(self):
        try:
            url = "http://10.59.9.18/small/commodity/verify/v1/addCommodityComment?"
            hed = {"userId": str(Test_wdds.uid), "sessionId": Test_wdds.sid}
            data = {"commodityId":"5","orderId":"2025090912424962229381","content":"good","image":""}
            res = requests.post(url=url,headers=hed,data=data)
            print("还没有收货的进行评价", res.json())
        except Exception as e:
            assert res.json()['status'] == 1004
            logging.info(e)

    def test_pl3(self):
        try:
            url = "http://10.59.9.18/small/commodity/verify/v1/addCommodityComment?"
            hed = {"userId": str(Test_wdds.uid), "sessionId": Test_wdds.sid}
            data = {"commodityId":"3","orderId":"2025090911241202329381","content":"good","image":""}
            res = requests.post(url=url,headers=hed,data=data)
            print("还没有支付的进行评价", res.json())
        except Exception as e:
            assert '确认收货后再来评论吧！' in res.json()
            logging.info(e)

    def test_pl4(self):
        try:
            url = "http://10.59.9.18/small/commodity/verify/v1/addCommodityComment?"
            hed = {"userId": str(Test_wdds.uid), "sessionId": Test_wdds.sid}
            data = {"commodityId":"3","orderId":"2025090911241202329381","content":"sdghkfsdkhgfsd","image":""}
            res = requests.post(url=url,headers=hed,data=data)
            print("还没有支付的进行评价并输入乱码", res.json())
        except Exception as e:
            logging.info(e)

    def test_pl5(self):
        try:
            url = "http://10.59.9.18/small/commodity/verify/v1/addCommodityComment?"
            hed = {"userId": str(Test_wdds.uid), "sessionId": Test_wdds.sid}
            data = {"commodityId":"5","orderId":"2023062414324050429381","content":"#￥#@￥%%%","image":""}
            res = requests.post(url=url,headers=hed,data=data)
            print("对已经评价过得输入特殊符号", res.json())
        except Exception as e:
            assert res.json()['status'] == 1004
            logging.info(e)


    def test_pl6(self):
        try:
            url = "http://10.59.9.18/small/commodity/verify/v1/addCommodityComment?"
            hed = {"userId": str(Test_wdds.uid), "sessionId": Test_wdds.sid}
            data = {"commodityId":"5","orderId":"2023062414324050429381","content":"#￥#@￥%%%","image":""}
            res = requests.post(url=url,headers=hed,data=data)
            print("对已经评价过得输入特殊符号", res.json())
        except Exception as e:
            assert res.json()['status'] == 1004
            logging.info(e)


    def test_pl7(self):
        try:
            url = "http://10.59.9.18/small/commodity/verify/v1/addCommodityComment?"
            hed = {"userId": str(Test_wdds.uid), "sessionId": Test_wdds.sid}
            data = {"commodityId":"5","orderId":"2023062414324050429381","content":"#￥#@￥%%%","image":""}
            res = requests.post(url=url,headers=hed,data=data)
            print("对已经评价过得输入特殊符号", res.json())
        except Exception as e:
            assert res.json()['status'] == 1004
            logging.info(e)

    def test_pl8(self):
        try:
            url = "http://10.59.9.18/small/commodity/verify/v1/addCommodityComment?"
            hed = {"userId": str(Test_wdds.uid), "sessionId": Test_wdds.sid}
            data = {"commodityId":"5","orderId":"2023062414324050429381","content":"#￥#@￥%%%","image":""}
            res = requests.post(url=url,headers=hed,data=data)
            print("对已经评价过得输入特殊符号", res.json())
        except Exception as e:
            assert res.json()['status'] == 1004
            logging.info(e)


    def test_pl8(self):
        try:
            url = "http://10.59.9.18/small/commodity/verify/v1/addCommodityComment?"
            hed = {"userId": str(Test_wdds.uid), "sessionId": Test_wdds.sid}
            data = {"commodityId":"5","orderId":"2023062414324050429381","content":"#￥#@￥%%%","image":""}
            res = requests.post(url=url,headers=hed,data=data)
            print("对已经评价过得输入特殊符号", res.json())
        except Exception as e:
            assert res.json()['status'] == 1004
            logging.info(e)





























